package leetcode;

import java.util.Arrays;

/**
 * @Description：
 * @Author：LiDong
 * @Create：2021/4/14
 * @Version：1.0.0
 */
public class Test1470 {

    public int[] shuffle(int[] nums, int n) {
        int[] arr1;
        int[] arr2 = new int[n];
        int[] arr = new int[nums.length];
        arr1 = Arrays.copyOf(nums, n);
        int x = 0;
        for (int i = n; i < nums.length; i++) {
            arr2[x] = nums[i];
            x++;
        }
        int num = 0;
        int p = 0;
        for (int i = 0; i < arr.length; i++) {
            // 拿 arr1z中的
            if (i % 2 == 0) {
                arr[i] = arr1[num];
            } else {
                arr[i] = arr2[num];
                p = i % 2;
            }
            if (p == 1) {
                num++;
                p = 0;
            }
        }
        return arr;
    }
}
